<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>comm</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_130">&nbsp;</a>NAME</h4><blockquote>
comm - select or reject lines common to two files
</blockquote><h4><a name = "tag_001_014_131">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

comm <b>[</b>-123<b>] </b><i>file1 file2</i>
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_132">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>comm</i>
utility
will read
<i>file1</i>
and
<i>file2</i>,
which should be ordered in the current collating sequence,
and produce three text columns as output: lines only in
<i>file1</i>;
lines only in
<i>file2</i>;
and lines in both files.
<p>
If the lines in both files are not ordered according to the
collating sequence of the current locale, the results are unspecified.
</blockquote><h4><a name = "tag_001_014_133">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>comm</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .
<p>
The following options are supported:
<dl compact>

<dt><b>-1</b>
<dd>Suppress the output column of lines unique to
<i>file1</i>.

<dt><b>-2</b>
<dd>Suppress the output column of lines unique to
<i>file2</i>.

<dt><b>-3</b>
<dd>Suppress the output column of lines duplicated in
<i>file1</i>
and
<i>file2</i>.

</dl>
</blockquote><h4><a name = "tag_001_014_134">&nbsp;</a>OPERANDS</h4><blockquote>
The following operands are supported:
<dl compact>

<dt><i>file1</i><dd>A pathname of the first file to be compared.
If
<i>file1</i>
is "-", the standard input is used.

<dt><i>file2</i><dd>A pathname of the second file to be compared.
If
<i>file2</i>
is "-", the standard input is used.

</dl>
<p>
If both
<i>file1</i>
and
<i>file2</i>
refer to standard input
or to the same FIFO special,
block special or character special file,
the results are undefined.
</blockquote><h4><a name = "tag_001_014_135">&nbsp;</a>STDIN</h4><blockquote>
The standard input will be used only if one of the
<i>file1</i>
or
<i>file2</i>
operands
refers to standard input.
See the INPUT FILES section.
</blockquote><h4><a name = "tag_001_014_136">&nbsp;</a>INPUT FILES</h4><blockquote>
The input files must be text files.
</blockquote><h4><a name = "tag_001_014_137">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>comm</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_COLLATE</i><dd>
Determine the locale for the
collating sequence
<i>comm</i>
expects to have
been used when the input files were sorted.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments and input files).

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
</dl>
</blockquote><h4><a name = "tag_001_014_138">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_139">&nbsp;</a>STDOUT</h4><blockquote>
The
<i>comm</i>
utility will produce output depending on the options selected.
If the
<b>-1</b>,
<b>-2</b>
and
<b>-3</b>
options are all selected,
<i>comm</i>
will write nothing to standard output.
<p>
If the
<b>-1</b>
option is not selected, lines contained only in
<i>file1</i>
will be written using the format:
<p><code>
<tt>"%s\n"</tt>, &lt;<i>line in file1</i>&gt;
</code>
<p>
If the
<b>-2</b>
option is not selected, lines contained only in
<i>file2</i>
will be written using the format:
<p><code>
<tt>"%s%s\n"</tt>, &lt;<i>lead</i>&gt;,
&lt;<i>line in file2</i>&gt;
</code>
where the string
&lt;<i>lead</i>&gt;
is:
<dl compact>

<dt>&lt;tab&gt;<dd>if the
<b>-1</b>
option is not selected, or

<dt>null string<dd>if the
<b>-1</b>
option is selected.

</dl>
<p>
If the
<b>-3</b>
option is not selected, lines contained in both files
will be written using the format:
<p><code>
<tt>"%s%s\n"</tt>, &lt;<i>lead</i>&gt;,
&lt;<i>line in both</i>&gt;
</code>
where the string
&lt;<i>lead</i>&gt;
is:
<dl compact>

<dt>&lt;tab&gt;&lt;tab&gt;<dd>if neither the
<b>-1</b>
nor the
<b>-2</b>
option is selected, or

<dt>&lt;tab&gt;<dd>if exactly one of the
<b>-1</b>
and
<b>-2</b>
options is selected, or

<dt>null string<dd>if both the
<b>-1</b>
and
<b>-2</b>
options are selected.

</dl>
<p>
If the input files were ordered according to the collating
sequence of the current locale, the lines written will be in
the collating sequence of the original lines.
</blockquote><h4><a name = "tag_001_014_140">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_001_014_141">&nbsp;</a>OUTPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_142">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_143">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>All input files were successfully output as specified.

<dt>&gt;0<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_001_014_144">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_145">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
If the input files are not properly presorted, the output of
<i>comm</i>
might not be useful.
</blockquote><h4><a name = "tag_001_014_146">&nbsp;</a>EXAMPLES</h4><blockquote>
If a file named
<b>xpg4</b>
contains a sorted list of the utilities
in this specification, a file named
<b>xpg3</b>
contains a sorted list
of the utilities specified in the
<b>X/Open Portability Guide</b>, <b>Issue 3</b>, and a file named
<b>svid89</b>
contains a sorted list of the utilities
in the System&nbsp;V Interface Definition Third Edition:
<pre>
<code>
comm -23 xpg4 xpg3 | comm -23 - svid89
</code>
</pre>
would print a list of utilities in this specification not specified
by either of the other documents;
<pre>
<code>
comm -12 xpg4 xpg3 | comm -12 - svid89
</code>
</pre>
would print a list of utilities specified by all three documents; and
<pre>
<code>
comm -12 xpg3 svid89 | comm -23 - xpg4
</code>
</pre>
would print a list of utilities specified by both XPG3 and the SVID,
but not specified in this specification.
</blockquote><h4><a name = "tag_001_014_147">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_148">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="cmp.html">cmp</a></i>,
<i><a href="diff.html">diff</a></i>,
<i><a href="sort.html">sort</a></i>,
<i><a href="uniq.html">uniq</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
